<?php
namespace app\supermanager\validate;
use think\Validate;
class FilialeManager extends Validate
{
	protected $rule = [
		'branch_num'   => 'require',
		'email'        => 'require|email',
		'phone'		   => 'require|checkPhone',
		'id_card'	   => 'require|checkIdCard'
		
	];
	
	protected $message = [
		'branch_num'  		=> '管理员账号不能为空',
		'email.require'     => '邮箱不能为空',
		'email.email'       => '邮箱格式错误',
		'phone.require'		=> '联系电话不能为空',
		'id_card.require'	=> '身份证号不能为空'
	];
	
	protected function checkPhone($value) {
		if(false === Validate::regex($value,'/^(13[0-9]|14[5|7]|15[0-9]|18[0-9]|17[0-9])\d{8}$/'))
		{
			return '联系电话格式错误';
		}
		return true;
	}
	protected  function checkIdCard($value){
		if(false === Validate::regex($value,'/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/i'))
		{
			return '身份证号格式错误';
		}
		return true;
	}
}

?>